import Vue from 'vue'
import Vuex from 'vuex'

Vue.use(Vuex)

const store = new Vuex.Store({
  state: {
    list:[]
  },
  mutations: {
    add(state,list){
    	//console.log(state)//所有公用数据
    	state.list.push(list)
    }
  },
  getters:{//过滤并计数   可以认为是 store 的计算属性
  	activelist(state){
  		return state.list.filter(item=>item.isChecked === false)
  	},
  	completelist(state){
  		return state.list.filter(item=>item.isChecked === true)
  	},
  	activenum(state){
  		return state.list.filter(item=>item.isChecked === false).length
  	}
  }
})

export default store